package io.renren.modules.milk.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.milk.dao.MilkRecordDao;
import io.renren.modules.milk.entity.MilkRecordEntity;
import io.renren.modules.milk.service.MilkRecordService;


@Service("milkRecordService")
public class MilkRecordServiceImpl extends ServiceImpl<MilkRecordDao, MilkRecordEntity>
        implements MilkRecordService {

    @Autowired
    private MilkRecordDao dao;

    /**
     * 单表分页查询
     */
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<MilkRecordEntity> page = this.selectPage(
                new Query<MilkRecordEntity>(params).getPage(),
                new EntityWrapper<MilkRecordEntity>()
        );
        return new PageUtils(page);
    }

    /**
     * 分页查询
     */
    @Override
    public PageUtils list4Page(Map<String, Object> params){
        Page<MilkRecordEntity> page = new Query<MilkRecordEntity>(params).getPage();
        return new PageUtils(page.setRecords(dao.list4Page(page, params)));
    }

    /**
     * 条件查询
     */
    @Override
    public List<MilkRecordEntity> listByCondition(Map<String, Object> params) {
        return dao.listByCondition(params);
    }

    /**
     * 逻辑删除多条记录
     */
    @Override
    public Boolean deleteLogic(List ids) {
        return dao.deleteLogic(ids);
    }

    /**
     * 根据id查询详情
     */
    @Override
    public MilkRecordEntity queryOneById(Long id) {
        return dao.queryOneById(id);
    }

    @Override
    public List<MilkRecordEntity> listByConditionYear(Map<String, Object> params) {
        return dao.listByConditionYear(params);
    }

}
